$(function (){
    let app = new Vue({
        el: "#app",
        data: {
            sysTitle: "固定资源管理系统",
            newPassword: "",
            celPassword: "",
            tell: "",
            tellCode: "",
            Info: ["新的密码：","确定密码：","手机号码：","验证码："],
            backImageSrc: "../../images/common/back.jpg",
        },
        onCreate(){

        },
        methods: {

        }
    });
    // 信息提示
    var pwd = $(".newpwd");
    var celpwd = $(".celpwd");
    var tell = $(".telltip");
    var inputs = $("input");
    var b = false;
    $.each(inputs, function (i, ele){
        $(ele).attr("inp", i);
        $(ele).focus(function (){
            if($(this).attr("inp") === "2")
            {
                if($(this).val().length !== 11)
                    tell.css("display", "block");
            }
            if($(this).attr("inp") === "0")
            {
                if($(this).val().length < 8)
                    pwd.css("display", "block");
            }
            if($(this).attr("inp") === "1")
            {
                if($(this).val().length < 8)
                    celpwd.css("display", "block");
            }
        });
        $(ele).blur(function (){
            if($(this).attr("inp") === "2")
            {
                if($(this).val().length === 11)
                {
                    tell.css("display", "none");
                }else {
                    $(this).focus();
                }
            }
            if($(this).attr("inp") === "0")
            {
                if($(this).val().length >= 8)
                {
                    pwd.css("display", "none");
                }else {
                    $(this).focus();
                }
            }
            if($(this).attr("inp") === "1")
            {
                if($(this).val().length >= 8)
                {
                    celpwd.css("display", "none");
                }else {
                    $(this).focus();
                }
            }
            if(inputs.eq(0).val() !== "" && inputs.eq(1).val() !== "" ){
                if(inputs.eq(0).val() !== inputs.eq(1).val())
                {
                    alert("密码不一致！");
                    if(b)
                    {
                        inputs.eq(1).val("");
                        inputs.eq(1).focus();
                        b = false;
                    }else {
                        inputs.eq(0).val("");
                        inputs.eq(0).focus();
                        b = true;
                    }
                }
            }
        });
    });

    //验证码
    var code = document.querySelector('.code');
    var i=60;
    code.addEventListener('click',function (){
        var codetime = setInterval(function (){
            code.innerText = '剩下'+i+'s';
            i--;
            code.disabled = true;
            code.style.color = 'red';
            if(i<=0)
            {
                clearInterval(codetime);
                code.disabled = false;
                code.innerText = '验证码';
                i=30;
                code.style.color = '#333';
            }
        },1000);
    });
});